#ifndef PERSPECTIVE_MANAGER_H
#define PERSPECTIVE_MANAGER_H

#include <iperspective.h>

#include <QtCore/QHash>
#include <QtCore/QObject>

namespace swp
{
class MainWindow;

class PerspectiveManager : public QObject
{
    Q_OBJECT

public:
    PerspectiveManager(MainWindow* parent = 0);
    ~PerspectiveManager();

    void addPerspective(core::IPerspective* perspective);
    void removePerspective(core::IPerspective* perspective);
    void setCurrent(core::IPerspective* current);

    const core::IPerspective* getCurrent() const;
    const QList<core::IPerspective* > perspectives() const;

    void ensurePerspectiveRequest(core::IPerspective* perspective);
    void ensurePerspectiveRequest(int index);

signals:
    void perspectiveChanged(core::IPerspective* perspective);
    void ensurePerspectiveRequested(int index);

public slots:
    void perspectiveChange(int index);

private slots:
    void ensureOfPerspective();
    void perspectiveShortcut();

private:
    core::IPerspective* m_currentPerspective;
    QList<core::IPerspective* > m_perspectives;
    QList<QAction* > m_actions;
    QHash<QAction*, core::IPerspective* > m_actionsToPerspetive;
    MainWindow* m_window;
};

} // namespace swp

#endif
